import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { AuthorityService } from './authority.service';
import { AssignAuthorityDto, CreateAuthorityDto } from './dto/create-authority.dto';
import { UpdateAuthorityDto } from './dto/update-authority.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';


@ApiTags('权限管理')
@Controller('admin/authority')
export class AuthorityController {
  constructor(private readonly authorityService: AuthorityService) { }

  @Post()
  @ApiOperation({
    summary: '创建权限',
  })
  async create(@Body() createAuthorityDto: CreateAuthorityDto) {
    return this.authorityService.create(createAuthorityDto);
  }

  @Patch(':id')
  @ApiOperation({
    summary: '修改权限',
  })
  async update(@Param('id') id: string, @Body() updateAuthorityDto: UpdateAuthorityDto) {
    return this.authorityService.update(id, updateAuthorityDto);
  }

  @Post("assignAuthority")
  @ApiOperation({
    summary: '分配权限',
  })
  async assignAuthority(@Body() assignAuthorityDto: AssignAuthorityDto) {
    return this.authorityService.assignAuthority(assignAuthorityDto);
  }

}
